﻿using System.IO;
using NUnit.Framework;
using OpenPowerPoint;
using OpenPowerPoint.Slides;

namespace OpenPowerPointTest.Initialisation
{
    /// <summary>
    /// Tests for a presentation template containing a single slide and no group
    /// </summary>
    [TestFixture]
    [Category("Integration: Initialisation")]
    class SinglePresentationInitialisation
    {
        private Presentation _presentation;
        private Stream _stream;

        #region Setup/Teardown
        [SetUp]
        public void Setup()
        {
            _stream = new MemoryStream(Presentations.single);

            _presentation = Presentation.LoadPresentation(_stream);
        }

        [TearDown]
        public void TearDown()
        {
            _stream.Close();
        }
        #endregion

        /// <summary>
        /// Test for the right Filename
        /// </summary>
        /// <remarks><seealso cref="Presentation.Filename"/></remarks>
        [Test]
        public void FileNameSet()
        {
            Assert.AreEqual("", _presentation.Filename, "Filename is set by initialisation from stream");
        }

        /// <summary>
        /// Test for the right Presentation type
        /// </summary>
        /// <remarks><seealso cref="Presentation.Type"/></remarks>
        [Test]
        public void PresentationType()
        {
            Assert.AreEqual(Presentation.PresentationType.Presentation, _presentation.Type,
                            "Presentationtype not recognized correctly");
        }

        /// <summary>
        /// Test for the right number of groups
        /// </summary>
        /// <remarks><seealso cref="Presentation.Groups"/></remarks>
        [Test]
        public void GroupsCount()
        {
            Assert.AreEqual(1, _presentation.Groups.Count, "Wrong number of Groups loaded");
        }

        /// <summary>
        /// Test for the right number of slides in the first group
        /// </summary>
        /// <remarks><seealso cref="SlideGroup.Slides"/></remarks>
        [Test]
        public void SlideCount()
        {
            Assert.AreEqual(1, _presentation.Groups[0].Slides.Count,"Wrong number of Slides loaded");
        }

        /// <summary>
        /// Test for the right number of slide masters
        /// </summary>
        /// <remarks><seealso cref="Presentation.SlideMasters"/></remarks>
        [Test]
        public void SlideMasterCount()
        {
            Assert.AreEqual(1, _presentation.SlideMasters.Count, "Wrong number of SlideMasters loaded");
        }

        /// <summary>
        /// Test for the right number of layouts in the first slide master
        /// </summary>
        /// <remarks><seealso cref="SlideMaster.Layouts"/></remarks>
        [Test]
        public void SlideLayoutCount()
        {
            Assert.AreEqual(1, _presentation.SlideMasters[0].Layouts.Count, "Wrong number of Layouts for MasterSlide 0 loaded");
        }
    }
}
